[#ftl]
<!DOCTYPE html>
<html>
<head>
<title>企业服务</title>
<css>
<link href="http://cdn.bootcss.com/jquery-footable/0.1.0/css/footable.css" rel="stylesheet">
</css>
<script src="http://cdn.bootcss.com/jquery-footable/0.1.0/js/footable.js"></script>
<script type="text/javascript">

function ajaxQuery(resultContainer)
{   
    $.ajax({
        type: "POST", //提交的类型 
        url:  "${base}/uyo/platStore/ajaxlist",//提交地址 
        data: $("#queryform").serializeArray(),//参数 
        //contentType: "application/json; charset=utf-8", 
        success: function(msg){//回调方法 
                    $(resultContainer).html(msg);
                }
    });     
}

$(function(){
   //  ajaxQuery("#dataTable");
});

//确认删除start
function deleteA(){
    var id = [];
    $("input[name='checkData']").each(function(){
            if($(this).attr("checked")=="checked"){
                id.push($(this).val());
            }
        });
    // 检查是否选择一个
    var len = id.length;
    if ( len== 0) {
        tips("请选择数据");
        return false;
     }
    else{
      if (confirm("确定要删除数据吗？")) {
          $.ajax({
               type : "post",
               url : "${base}/uyo/platStore/"+id+"/delete",
               traditional:true,
               dataType: "json",
               success: function(data){ 
                var messages = extendMessages(data);
                        noty({
                                 text:extendMessages(data).msg.message,
                                  layout:"center",
                                  timeout:2000,
                                  callback:{
                                    afterShow:function(){                                  
                                        if(messages.isAllSuccess())
                                        {
                                            ajaxQuery("#dataTable");
                                        }
                                    }
                                  }                          
                       });
                },
                error:function(){
                }
         }); 
       } 
   }           
}

//审核通过，发布文章
function publishA(param){
var thisNode=$(param).parent().parent();
      var id=thisNode.find("input:eq(0)").attr("value");
      $.ajax({
           type : "post",
           url : "${base}/uyo/platStore/"+id+"/publish",
           traditional:true,
           dataType: "json",
           success: function(data){ 
            var messages = extendMessages(data);
                    noty({
                             text:extendMessages(data).msg.message,
                              layout:"center",
                              timeout:2000,
                              callback:{
                                afterShow:function(){                                  
                                    if(messages.isAllSuccess())
                                    {
                                        $(param).remove();
                                    }
                                }
                              }                          
                   });
            },
            error:function(){
            }
     });
}

//确认删除end
//条件查询
 function conditionQuery(){
      var $startTime=$("#startTime").val();
      var $endTime=$("#endTime").val();
      if($startTime!=null&&$startTime!=""&&$endTime!=null&&$endTime!=""&&($startTime>$endTime)){
           tips('起始时间不能晚于截止时间');
      }else{ 
           $("#nowpager").val(1);
           ajaxQuery("#dataTable");
      }               
 }
 function addA(){
     var categoryId=$("#categoryId").val();
     var page = $("#nowpager").val();
     window.location.href="${base}/uyo/platStore/add?categoryId="+categoryId+"&module=${module!'-1'}";
       
 } 
  function updateA(param){

     window.location.href="${base}/uyo/platStore/"+param+"/update?module=${module!'-1'}";

 } 
 function showArticle(param){
 
      window.location.href="${base}/uyo/platStore/"+param+"?module=${module!'-1'}";
 
 }  
 /*选择类别*/
function changeCategory(){
        var selectedId=$("#categoryId").val();
        d=dialog({
            url:'${base}/uyo/platStoreCategory/dataTree?selectedId='+selectedId,  
            title: '选择企业分类',
          //  background: '#EEE', // 背景色
            opacity: 0.05,  // 透明度
            width: 300,
            height: 350
          });   
          d.show();
}

/*清空类别*/
function cleanCategory(){ 
      $("#categoryId").val(null); 
      $("#categoryName").val(''); 
}

// 全选按钮选中标志  
    var checkflag = "false";  
    // 全选功能  
    function selectAll(){  
        var field = document.getElementsByName("checkData");  
        // 如果全选按钮状态是未选中  
        if (checkflag == "false"){  
            for (i = 0; i < field.length; i++){  
                field[i].checked = true;  
            }  
            // 更改全选按钮选中标志  
            checkflag = "true";  
        }else{  
            for (i = 0; i < field.length; i++){  
                field[i].checked = false;   
            }  
            // 更改全选按钮选中标志  
            checkflag = "false";  
        }  
    } 
    
    
    var $table;
$(function(){
     [#--data table--]
 	 $table = $('#dataTable').dataTable({
 	    "language": {
                		"url": "${base}/plugins/datatables/plugins/i18n/Chinese.json"
                   },
 	    "bServerSide": true,
 	    "bProcessing": true,
 	    "bPaginate": true,
 	    "bLengthChange": true, //改变每页显示数据数量
        "bFilter": true,
        "bSort": false,
        "bSortable_(0)":false,
        "bInfo": true,
        "bAutoWidth": false,
 		"ajax":   {
 			url:"${base}/uyo/platStore/ajaxlist/json",
 			data: function(d){ 	
 				d.categoryId = $("#categoryId").val();		        
 			   }
 			},
        "columns":[
        			{"data": "id", // 设置
			         "className":"nowrap",
			         "render": function ( data, type, full, meta ) {
					      return   '<input type="checkbox" name="checkData" value=""'+data+'>';
					    } 
			        },
        			{"data": "type",
        			 "render":function(data,type,full,meta){
			            if(data ==1)
			            {
			         		return "公司";
			         	}
			         	return "分店";
			          } 
        			},
			        {"data": "categoryName"},
			        {"data": "name"},
			        {"data": "description"},
			        {"data": "status",
        			 "render":function(data,type,full,meta){
			            if(data ==0)
			            {
			         		return "审核中";
			         	}
			         	else if(data ==1){
			         		return "正常";
			         	}
			         	return "关闭";
			          } 
        			},
			        {"data": "id", // 设置
			         "className":"nowrap",
			         "render": function ( data, type, full, meta ) {
					      return   '<a href="###" onclick="update('+data+')">修改</a>';
					    } 
			        } 
        		 ]
 	});
 	
 	$('.footable').footable();	 	 
});
</script>
</head>
<body> 
    <section class="content-header">
      <h1>
      	  系统管理>公司管理
      </h1>
      <ol class="breadcrumb">
              <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
              <li class="active">Dashboard</li>
            </ol>
    </section>
    <section class="invoice">
      <form id="queryform" class="form-horizontal" method="post">
       <div class="row invoice-info page-header">
         <div class="box">
            <div class="box-header ui-sortable-handle" style="cursor: move;">
              <i class="fa  fa-search"></i>
			  <h4 class="box-title">条件查询</h4>
              <div class="box-tools pull-right">
                <button data-widget="collapse" class="btn btn-primary btn-sm"><i class="fa fa-minus"></i></button>
              </div>
            </div>
            <div class="box-body border-radius-none" style="display: block;">
		          <div class="col-sm-3 invoice-col">
			          <label class="box-title col-lg-5"><h5>类型：</h5></label>	                  
			          <div class="col-lg-6">
			             <select class="form-control" name="type" id="type">
				             <option>全部</option>
				             <option value='1'>公司</option>
				             <option value='2'>分店</option>
						 </select>             
			          </div> 
			      </div>
			      <div class="col-sm-4 invoice-col">
			          <label class="box-title col-lg-4"><h5>名称：</h5></label>	                  
			          <div class="col-lg-6">
			             <input type="text" class="required form-control" id="name" name="name"/>            
			          </div> 
			      </div>
			      <div class="col-sm-3 invoice-col">
			          <label class="box-title col-lg-5"><h5>状态：</h5></label>	                  
			          <div class="col-lg-6">
			             <select id="status" name="status" class="form-control">
							    <option>全部</option>
							    <option value='0' >审核中</option>
					            <option value='1' >正常</option>
					            <option value='2' >关闭</option>
					          </select>           
			          </div> 
			      </div> 
			      <div class="col-sm-1 invoice-col">
			          <div class="col-sm-12 ">
			                 <button type="button"  class="btn btn-default"  onclick="conditionQuery();">查询</button>
			          </div >    
		          </div> 
	         </div>   
	      </div>         
       </div>
       <div class="row  page-header">
            <div class="col-xs-12">
                <button type="button" class="btn btn-primary" id="thisAdd"  onclick='addA()'>添加</button>
		        <button type="button" class="btn btn-default" id="deleteDatas" onclick='deleteA()'>删除</button>	
            </div><!-- /.col -->
       </div>
       <div class="row">
            <div class="col-xs-12">
              <div class="box">
                <div class="box-header">
                  <h3 class="box-title">公司列表</h3>
                </div><!-- /.box-header -->
                <input type="hidden" name="categoryId" id="categoryId" value="${(elem.categoryId)!0}">
	            <input type="hidden" name="ownerId" id="ownerId" value="${(loginUser.id)!0}">
	            <input type="hidden" name="userid" id="userid" value="${(loginUser.id)!0}">
	            <input type="hidden" name="categoryCode" id="categoryCode" value="${(elem.categoryCode)!''}">
	            <input type="hidden" name="page" id="nowpager" value="${(pager.page)!1}">
	            
                <div class="box-body">
					<div id="example2_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
					   <div class="row">
					      <div class="col-sm-6"></div>
					      <div class="col-sm-6"></div>
					   </div>
					   <div class="row">
						  <div class="col-sm-12 table-responsive">
							 <table id="dataTable" class=" footable table table-bordered table-hover dataTable  table-striped" role="grid">
							    <thead>
							       <tr role="row">
								       <th>
								            <input type="checkbox" onclick="selectAll()">全选
								       </th>
								       <th tabindex="0" aria-controls="example2" rowspan="1" colspan="1">类型</th>
								       <th tabindex="0" aria-controls="example2" rowspan="1" colspan="1" data-hide="phone">类别</th>
								       <th tabindex="0" aria-controls="example2" rowspan="1" colspan="1">名称</th>
								       <th tabindex="0" aria-controls="example2" rowspan="1" colspan="1" data-hide="phone,tablet">描述</th>
								       <th tabindex="0" aria-controls="example2" rowspan="1" colspan="1" data-hide="phone">状态</th>
								       <th tabindex="0" aria-controls="example2" rowspan="1" colspan="1">操作</th>
							       </tr>
							    </thead>  
							</table> 
						  </div>	
					   </div>	      
                    </div>
                </div>                 
             </div>
           </div>  
       </div>
     </form>  
    </section>

</body>
</html>
